﻿using MyDotNetCodes.日志;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //写Windows系统日志测试
            TestWindowsEventLog();

            //经纬度转化测试
            //LonLatConvertToolTest();



            #region 随机数测试
            Random ran = new Random(10);
            for (int i = 0; i < 500; i++)
            {
                int RandKey = ran.Next(0, 10);
                Console.WriteLine(RandKey);
                if (i == 100)
                {
                    //Console.Read();
                }
            }

            #endregion

            #region Ping功能
            string ipStr = "10.102.2.222";
            IPAddress ip;
            if (IPAddress.TryParse(ipStr, out ip))
            {
                try
                {
                    Ping pingSender = new Ping();
                    PingReply reply = pingSender.Send(ipStr, 20);//第一个参数为ip地址，第二个参数为ping的时间 
                    if (reply.Status != IPStatus.Success)
                    {
                        Console.WriteLine(ipStr + "网络不通畅，请检查线路！！");
                        //return;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Ping:" + ipStr + ex.ToString());
                }

            }
            #endregion

            Console.Read();
            Console.ReadLine();
        }

        /// <summary>
        /// 经纬度转化测试
        /// </summary>
        private static void LonLatConvertToolTest()
        {
            string digital1 = "113.211";
            string result = MyDotNetCodes.LonLatConvertTool.ConvertDigitalToDegrees(digital1);
            Console.WriteLine("数字字符串转度分秒：" + digital1 + " => " + result);

            double digtal2 = 113.211;
            string result2 = MyDotNetCodes.LonLatConvertTool.ConvertDigitalToDegrees(digtal2);
            Console.WriteLine("数字转度分秒：" + digtal2 + " => " + result);

            string degree = "113°12′39.6″";
            double result3 = MyDotNetCodes.LonLatConvertTool.ConvertDegreesToDigital(degree);
            Console.WriteLine("度分秒转数字：" + degree + " => " + result);
        }


        /// <summary>
        /// 写Windows系统日志测试
        /// </summary>
        private static void TestWindowsEventLog()
        {
            WindowsEventLogTool.OutSystemLog("图景快手", "信息一", EventLogEntryType.Information);
            WindowsEventLogTool.OutSystemLog("图景快手", "警告一", EventLogEntryType.Warning);
            WindowsEventLogTool.OutSystemLog("图景快手", "错误一", EventLogEntryType.Error);
        }
    }
}
